<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户信息列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="white-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>商家名称：</label>
                            <input type="text" name="shopName"/>
                        </li>
                        <li>
                            <label>测评店：</label>
                            <select name="isTests" th:with="type=${@dict.getType('sys_yes_no')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 80px;">城市中心店：</label>
                            <select name="isFocus" th:with="type=${@dict.getType('sys_yes_no')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>商户状态：</label>
                            <select name="examineStatus" th:with="type=${@dict.getType('t_examine_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="operator:shop:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.editFull()"
               shiro:hasPermission="operator:shop:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="operator:shop:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="operator:shop:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: layout-latest-js"/>
<script th:inline="javascript">

    var examineFlag = [[${@permission.hasPermi('operator:shop:examine')}]];
    var editFlag = [[${@permission.hasPermi('operator:shop:edit')}]];
    var removeFlag = [[${@permission.hasPermi('operator:shop:remove')}]];
    var syncFlag = [[${@permission.hasPermi('operator:shop:synchronous')}]];

    var examineStatusDatas = [[${@dict.getType('t_examine_status')}]];
    var prefix = ctx + "operator/shop";

    $(function () {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 200});
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "商户信息",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'shopId',
                    title: '商户Id'
                },
                {
                    field: 'shopName',
                    title: '商户名称'
                },
                {
                    field: 'shopImg',
                    title: '商户图片',
                    visible: false,
                    formatter: function (value) {
                        if (value) {
                            return "<img src='" + value + "' style='height: 36px;' target='_blank' tile='点击查看' "
                                + "onclick='$.operate.alertPic(" + value + "\")' />";
                        }
                    }
                },
                {
                    field: 'examineStatus',
                    title: '商户状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(examineStatusDatas, value);
                    }
                },
                {
                    field: 'examineDesc',
                    title: '审核描述',
                    visible: false
                },
                {
                    field: 'city',
                    title: '所在城市'
                },
                {
                    field: 'deptName',
                    title: '所属部门'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + examineFlag + '" href="javascript:void(0)" onclick="examinePage(\'' + row.shopId + '\')"><i class="fa fa-credit-card"></i>审核</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + syncFlag + '" href="javascript:void(0)" onclick="synchronous(\'' + row.shopId + '\')"><i class="fa fa-refresh "></i>同步</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.shopId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.shopId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    /**
     * 审核页面
     * @param shopId
     */
    function examinePage(shopId) {
        $.modal.open("审核商户信息",
            prefix + "/examine/" + shopId);
    }

    /**
     * 同步用戶
     * @param shopId
     */
    function synchronous(shopId) {
        $.modal.confirm("确认要同步商户管理员信息吗？", function() {
            $.modal.loading("正在初始化用户数据，请稍后...");
            $.post(prefix + "/synchronous", {shopId}, function(result) {
                if (result.code == 0) {
                    console.log(result)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        })
    }

</script>
</body>
</html>
